home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / cad_elec / gerbtool.exe / DATA.1 / DRCVIEW.MAC < prev    next >
Text File  |  1995-01-23  |  5KB  |  234 lines

  1. MACRO startup
  2. # Comment out the following SETGLOBAL if you dont want DRCview to
  3. # remember what line to start on.
  4.  
  5.     SetGlobal $lineNo = 0
  6. END
  7.  
  8. MACRO DRCview
  9.  
  10. # This macro provides an improved diplay of DRC errors.
  11. # The report generated by the Tools/DRC command is used to walk thru
  12. # the list of DRC errors.
  13.  
  14.     IF $$VERSION < 5.2
  15.         # version check!
  16.         Stop "This macro requires at least V5.2!"
  17.     END
  18.  
  19.     GetString "Enter DRC report filename:", $drcfile
  20.  
  21.     FileOpen $fd, $drcfile, "r"
  22.  
  23.     IF $$STATUS
  24.  
  25.         IF $lineNo > 0
  26.  
  27.             StrWrite $buf, "Continue at line %n?", $lineNo
  28.             MessageBox "DRCVIEW", $buf, 2
  29.  
  30.             IF $$STATUS == $$TRUE
  31.  
  32.                 Set $lcnt = 1
  33.  
  34.                 REPEAT $lcnt < $lineNo
  35.  
  36.                     FileRead $fd, "", $line
  37.  
  38.                     IF $$STATUS == 0
  39.                         STOP "File read error!"
  40.                     END
  41.  
  42.                     Calc $lcnt = $lcnt + 1
  43.  
  44.                 END
  45.  
  46.             ELSE
  47.                 Calc $lineNo = 0
  48.             END
  49.  
  50.         END
  51.  
  52.         FileRead $fd, "", $line
  53.  
  54.         REPEAT $$STATUS
  55.  
  56.             Calc $lineNo = $lineNo + 1
  57.  
  58.             # check for a new layer... (need a strncmp)
  59.  
  60.             StrSub $buf, 1, 5, $line
  61.             StrCmp $buf, "Layer"
  62.  
  63.             IF $$STATUS == 0
  64.                 StrRead $line, "Layer %n", $layer
  65.             END
  66.  
  67.             StrLoc $line, "["            # were only interested in lines with sequence numbers....
  68.  
  69.             IF $$STATUS > 0
  70.  
  71.                 StrLoc $line, ":"
  72.                 Calc $len = $$STATUS
  73.  
  74.                 StrSub $minact, $len + 2, 18, $line            # pull out min/act
  75.  
  76.                 StrSub $serrtype, 1, $len - 1, $line
  77.                 StrCmp $serrtype, "Pad/Pad"
  78.  
  79.                 # determine error type...
  80.  
  81.                 IF $$STATUS == 0
  82.                     Calc $errtype = 2
  83.                 ELSE
  84.  
  85.                     StrCmp $serrtype, "Pad/Trace"
  86.  
  87.                     IF $$STATUS == 0
  88.                         Calc $errtype = 2
  89.                     ELSE
  90.  
  91.                         StrCmp $serrtype, "Trace/Trace"
  92.  
  93.                         IF $$STATUS == 0
  94.                             Calc $errtype = 2            # errors with involving two items...
  95.                         ELSE
  96.                             Calc $errtype = 1            # everything else is a single item error
  97.                         END
  98.  
  99.                     END
  100.  
  101.                 END
  102.  
  103.                 IF $errtype == 2
  104.  
  105.                     StrLoc $line, "["
  106.                     StrSub $seqnos, $$STATUS, 200, $line
  107.                     StrRead $seqnos, "[%n,%n", $item1, $item2
  108.  
  109. #                    MeasureE2E $layer, $item1, $item2
  110. #                    Calc $dist = $$STATUS
  111.  
  112.                     # GetFirstItem now checks the seqno passed in and, if valid, starts at that item...
  113.  
  114.                     GetFirstItem $layer, $item1, $net, $dcode, $type, $x1, $y1, $x2, $y2, $dia, $cw, $flags
  115.                     GetFirstItem $layer, $item2, $net, $dcode, $type, $x3, $y3, $x4, $y4, $dia, $cw, $flags
  116.  
  117.                     CallMacro "CalcBoundingBox", $x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4
  118.  
  119.                     ViewWindow $x1,$y1, $x2,$y2
  120.  
  121.                     HiliItem $layer, $item1
  122.                     HiliItem $layer, $item2
  123.  
  124. #                    StrWrite $buf, " %s:  Distance: %.5n,  touch a key to continue...", $serrtype, $dist
  125.                     StrWrite $buf, " %s: %s,  touch a key to continue...", $serrtype, $minact
  126.                     Pause 0, "DRCVIEW", $buf
  127.  
  128.                 ELSE
  129.  
  130.                     StrLoc $line, "["
  131.                     StrSub $seqnos, $$STATUS, 200, $line
  132.                     StrRead $seqnos, "[%n", $item1
  133.  
  134.                     GetFirstItem $layer, $item1, $net, $dcode, $type, $x1, $y1, $x2, $y2, $dia, $cw, $flags
  135.  
  136.                     Calc $x3 = $x1            # duplicate the first coord set
  137.                     Calc $y3 = $y1            # so they are effectively ignored...
  138.                     Calc $x4 = $x1
  139.                     Calc $y4 = $y1
  140.  
  141.                     CallMacro "CalcBoundingBox", $x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4
  142.  
  143.                     ViewWindow $x1,$y1, $x2,$y2
  144.  
  145.                     HiliItem $layer, $item1
  146.  
  147.                     StrCmp $serrtype, "Missing Drill"
  148.  
  149.                     IF $$STATUS == 0
  150.                         StrWrite $buf, " %s: touch a key to continue...", $serrtype
  151.                     ELSE
  152.                         StrWrite $buf, " %s: %s,  touch a key to continue...", $serrtype, $minact
  153.                     END
  154.  
  155.                     Pause 0, "DRCVIEW", $buf
  156.  
  157.                 END
  158.  
  159.             END
  160.  
  161.             FileRead $fd, "", $line
  162.  
  163.         END
  164.  
  165.         FileClose $fd
  166.  
  167.     END
  168.  
  169.     Calc $lineNo = 0
  170.  
  171. END
  172.  
  173. MACRO CalcBoundingBox
  174.  
  175. # This sub-macro calculates the bounding rectangle of set of four XY coordinates.
  176. # usage:    CallMacro "CalcBoundingBox", $x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4
  177.  
  178.     Calc $lx = $1
  179.     Calc $ly = $2
  180.  
  181.     IF $3 < $lx
  182.         Calc $lx = $3
  183.     END
  184.     IF $5 < $lx
  185.         Calc $lx = $5
  186.     END
  187.     IF $7 < $lx
  188.         Calc $lx = $7
  189.     END
  190.     IF $4 < $ly
  191.         Calc $ly = $4
  192.     END
  193.     IF $6 < $ly
  194.         Calc $ly = $6
  195.     END
  196.     IF $8 < $ly
  197.         Calc $ly = $8
  198.     END
  199.  
  200.     Calc $ux = $1
  201.     Calc $uy = $2
  202.  
  203.     IF $3 > $ux
  204.         Calc $ux = $3
  205.     END
  206.     IF $5 > $ux
  207.         Calc $ux = $5
  208.     END
  209.     IF $7 > $ux
  210.         Calc $ux = $7
  211.     END
  212.     IF $4 > $uy
  213.         Calc $uy = $4
  214.     END
  215.     IF $6 > $uy
  216.         Calc $uy = $6
  217.     END
  218.     IF $8 > $uy
  219.         Calc $uy = $8
  220.     END
  221.  
  222. # return the bounding rect in the first four parameters...
  223.  
  224.     Calc $1 = $lx - .2
  225.     Calc $2 = $ly - .2
  226.     Calc $3 = $ux + .2
  227.     Calc $4 = $uy + .2
  228.  
  229. END
  230.  
  231. MACRO drcviewinit
  232.     SetGlobal $lineNo = 0
  233. END
  234.